package com.lzw.mapper.maintenance;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

@Mapper
public interface MaintenanceWorkerMapper {
    @Select("SELECT worker_id FROM dormitorymanagement.maintenanceworker WHERE username = #{username} AND password = #{password}")
    Integer checkCredentials(@Param("username") String username, @Param("password") String password);

    @Select("SELECT worker_id, name, username, gender, phone, email,availability_status FROM dormitorymanagement.maintenanceworker WHERE username = #{username} AND password = #{password}")
    Map<String, Object> getMaintenanceInfo(@Param("username") String username, @Param("password") String password);

    @Select("SELECT worker_id, name, username, gender, phone, email, availability_status FROM dormitorymanagement.maintenanceworker WHERE worker_id = #{workerId}")
    Map<String, Object> getMaintenanceInfoById(@Param("workerId") Integer workerId);

    @Update("UPDATE dormitorymanagement.maintenanceworker SET name = #{name}, gender = #{gender}, phone = #{phone}, email = #{email} WHERE worker_id = #{workerId}")
    int updateMaintenanceInfo(@Param("workerId") Integer workerId, @Param("name") String name,
                                  @Param("gender") String gender, @Param("phone") String phone,
                                  @Param("email") String email);
}
